﻿using ClassLibrary1;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace WebApplication1.Pages
{
    public class IndexModel : PageModel
    {
        private readonly ILogger<IndexModel> _logger;
        private readonly IRabbitMqMessagePublisher _rabbitMqMessagePublisher;

        public IndexModel(ILogger<IndexModel> logger, 
            IRabbitMqMessagePublisher rabbitMqMessagePublisher)
        {
            _logger = logger;
            _rabbitMqMessagePublisher = rabbitMqMessagePublisher;
        }

        public void OnGet()
        {
            _rabbitMqMessagePublisher.Publish(new TestMessageObj { Message = "bbb" });
            _rabbitMqMessagePublisher.Publish(new Test2MessageObj { Name = "name" });
        }
    }
}